from sqlmodel import SQLModel, Field, Index
from datetime import datetime

class TradingPair(SQLModel, table=True):
    """Waveup交易对表数据库模型"""
    __tablename__ = "t_trading_pair"  # 对应数据库表名

    # 索引定义（优化查询性能）
    __table_args__ = (
        Index("idx_productPairId", "productPairId", unique=True, info="交易对编码唯一索引"),
    )

    # 字段定义
    id: int = Field(default=None, primary_key=True, index=True, description="主键ID")
    productPairId: str = Field(default="", max_length=32, description="交易对编码")
    productPairName: str = Field(default="", max_length=128, description="交易对名称")
    tradeStatus: int = Field(default=0, description="交易对状态（0：停用，1：正常）")
    productIdA: str = Field(default="", max_length=64, description="交易对资产A编码")
    productNameA: str = Field(default="", max_length=128, description="交易对资产A名称")
    productImageA: str = Field(default="", max_length=256, description="交易对资产A图片URL")
    productIdB: str = Field(default="", max_length=64, description="交易对资产B编码")
    productNameB: str = Field(default="", max_length=128, description="交易对资产B名称")
    productImageB: str = Field(default="", max_length=256, description="交易对资产B图片URL")
    lockAmountA: float = Field(default=0.0, description="交易对资产A锁仓金额")
    lockAmountB: float = Field(default=0.0, description="交易对资产B锁仓金额")
    lockAmountK: float = Field(default=0.0, description="交易对资产K锁仓金额")
    platformFeeRate: float = Field(default=0.0, description="平台手续费率")
    poolFeeRate: float = Field(default=0.0, description="交易对资产K锁仓金额")
    slipPageRange: str = Field(default="", max_length=64, description="滑点页面范围")
    createdAt: datetime = Field(default_factory=datetime.now, description="创建时间")
    updatedAt: datetime = Field(default_factory=datetime.now, description="更新时间")